package utils

type VarList struct {
	lst []interface{}
}

func NewVarList() *VarList {
	rval := &VarList{}
	return rval
}

func (this *VarList) AppendVal(val interface{}) *VarList {
	this.lst = append(this.lst, val)
	return this
}

func (this *VarList) Reset() *VarList {
	this.lst = make([]interface{}, 0)
	return this
}

func (this *VarList) RandVars(n int, makefn func(idx int) interface{}) *VarList {
	lst := make([]interface{}, n)
	for i := 0; i < len(lst); i++ {
		lst[i] = makefn(i)
	}
	this.lst = lst
	return this
}

func (this *VarList) GetValueCycle(n int) interface{} {
	lst := this.lst
	v := n % len(lst)
	return lst[v]
}
